package com.pingan.glue.gluegame.aip.impl;

import com.alibaba.fastjson.JSONObject;
import com.pingan.glue.gluegame.aip.APIService;
import com.pingan.glue.gluegame.aip.domain.AIPResponse;
import com.pingan.glue.gluegame.aip.domain.FaceAddDto;
import com.pingan.glue.gluegame.aip.domain.FaceFieldDto;
import com.pingan.glue.gluegame.aip.domain.FaceSearchDto;
import com.pingan.glue.gluegame.http.GlueGameClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("gamma")
public class GammaAPIServiceImpl implements APIService {

    private final static Logger LOGGER = LoggerFactory.getLogger(GammaAPIServiceImpl.class);


    private static final String URL_FACE_DELETE="/rest/emotion/detect";
    private static final String URL_FACE_MIANXIANG_DELETE="/rest/mianxiang/detect";



    private String faceUrl ="http://202.69.30.144:8080";


    @Resource
    private GlueGameClient glueGameClient;

    @Override
    public String auth() {
        return null;
    }

    @Override
    public JSONObject add(FaceAddDto dto) {
        return null;
    }

    @Override
    public JSONObject update(FaceAddDto dto) {
        return null;
    }

    @Override
    public String faceDelete(FaceAddDto dto) {

        return null;
    }

    @Override
    public FaceFieldDto detect(String image) {
        LOGGER.info("GammaAPIServiceImpl_detect_image={}",image);
        JSONObject body = new JSONObject();
        body.put("data",image);
        body.put("type",0);
        JSONObject json = glueGameClient.post(faceUrl+URL_FACE_MIANXIANG_DELETE,"",body);
        LOGGER.info("GammaAPIServiceImpl_detect_result={}",json.toJSONString());

        return null;
    }

    @Override
    public AIPResponse search(FaceSearchDto dto) {
        return null;
    }
}
